const Controller = require('egg').Controller;

class Xue extends Controller {
    async index(){
        let data = await this.app.model.Xue.findAll();
        this.ctx.body = data
    }
    async create(){
        try{
            let name=this.ctx.request.body.name;
            let chengji=this.ctx.request.body.chengji;
            let id=this.ctx.request.body.id;
            await this.app.model.Xue.create({
                name:name,
                clazz_id:id,
                chengji:chengji,    
            })
            this.ctx.redirect('/xue');
        }catch{
            this.ctx.body='添加错误'
        }
        // console.log(name,chengji);
        
    }
    async update(){

    }
    async destroy(){
        
    }
} 

module.exports = Xue;